//
//  UIImage+ImageCut.m
//  ImageTool
//
//  Created by Apple on 2017/6/5.
//  Copyright © 2017年 Apple. All rights reserved.
//

#import "UIImage+ImageCut.h"

@implementation UIImage (ImageCut)


-(UIImage *)ImageCutSize:(CGRect)rect
{
    CGImageRef subImageref = CGImageCreateWithImageInRect(self.CGImage, rect);
    CGRect smallRef = CGRectMake(0, 0, CGImageGetWidth(subImageref), CGImageGetHeight(subImageref));
    
    UIGraphicsBeginImageContext(smallRef.size);
    
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextDrawImage(context, smallRef, subImageref);
    UIImage *image = [UIImage imageWithCGImage:subImageref];
    
    UIGraphicsEndImageContext();
    return image;
}

@end
